import { httpData, unknownType } from '@/utils/types';
import { get, post } from '@/utils/request';

export function getSelectListByParams(params: Record<string, any>): Promise<any> {
    return get('/common/getPullDownOne', params);
}

// 下拉转换
export function getTransform(data?: any) {
    return data?.map((item: any) => {
        return {
            text: item.label,
            value: item.value,
        };
    });
}

export default {
    getTransform,
    /**
     * 用户列表
     */
    userList: (): Promise<any> => get('/api/v1/user/manage/selectNoPage'),

    //**************************************  公共下拉  **************************************
    // 组织名称 - 组织表
    getCompanyName: (): Promise<any> => getSelectListByParams({ type: 48, field: 'name' }),

    // 生产管理-充装工单-充后检查
    fillingAfterInspect: (): Promise<any> => getSelectListByParams({ type: 1, field: 'name' }),

    // 生产管理-充装工单-充后登记详情
    fillingAfterRegistration: (): Promise<any> => getSelectListByParams({ type: 2, field: 'name' }),

    // 生产管理-充装工单-充后登记
    fillingAfterRegistrationDetail: (): Promise<any> => getSelectListByParams({ type: 3, field: 'name' }),

    // 生产管理-充装工单-充装批次
    fillingBatch: (): Promise<any> => getSelectListByParams({ type: 4, field: 'name' }),

    // 生产管理-充装工单-充装批次关联气瓶
    fillingBatchCylinderRelate: (): Promise<any> => getSelectListByParams({ type: 5, field: 'name' }),

    // 生产管理-充装工单-充前检查
    fillingBeforeInspect: (): Promise<any> => getSelectListByParams({ type: 6, field: 'name' }),

    // 生产管理-充装工单-充前登记
    fillingBeforeRegistration: (): Promise<any> => getSelectListByParams({ type: 7, field: 'name' }),

    // 生产管理-充装工单-充装试漏
    fillingLeakTest: (): Promise<any> => getSelectListByParams({ type: 8, field: 'name' }),

    // 生产管理-充装工单-充装登记记录
    fillingRecord: (): Promise<any> => getSelectListByParams({ type: 9, field: 'name' }),

    // 生产管理-充装工单-抽空置换
    fillingReplacement: (): Promise<any> => getSelectListByParams({ type: 10, field: 'name' }),

    // 生产管理-充装工单-抽空置换抽空后详情
    fillingReplacementAfter: (): Promise<any> => getSelectListByParams({ type: 11, field: 'name' }),

    // 生产管理-充装工单-抽空置换抽空前详情
    fillingReplacementBefore: (): Promise<any> => getSelectListByParams({ type: 12, field: 'name' }),

    // 表单记录
    formRecord: (): Promise<any> => getSelectListByParams({ type: 13, field: 'name' }),

    // 表单配置
    formSet: (): Promise<any> => getSelectListByParams({ type: 14, field: 'name' }),

    // 表单配置-采集项目
    formCollection: (): Promise<any> => getSelectListByParams({ type: 15, field: 'name' }),

    // 生产管理-物料回收
    materialRecovery: (): Promise<any> => getSelectListByParams({ type: 16, field: 'name' }),

    // 生产管理-物料回收汇出（入）后录入
    materialRecoveryAfterEntry: (): Promise<any> => getSelectListByParams({ type: 17, field: 'name' }),

    // 生产管理-物料回收汇出（入）前录入
    materialRecoveryBeforeEntry: (): Promise<any> => getSelectListByParams({ type: 18, field: 'name' }),

    // 生产管理-物料回收记录
    materialRecoveryRecord: (): Promise<any> => getSelectListByParams({ type: 19, field: 'name' }),

    // 生产管理-生产工单-生产投料
    productionFeedMaterial: (): Promise<any> => getSelectListByParams({ type: 20, field: 'name' }),

    // 生产管理-生产工单-生产投料记录
    productionFeedMaterialRecord: (): Promise<any> => getSelectListByParams({ type: 21, field: 'name' }),

    // 生产管理-生产工单-生产投料记录详情
    productionFeedMaterialRecordDetail: (): Promise<any> => getSelectListByParams({ type: 22, field: 'name' }),

    // 生产管理-产线运行工单-工艺路径
    runRecord: (): Promise<any> => getSelectListByParams({ type: 23, field: 'name' }),

    // 生产管理-产线运行工单-异常中断
    runRecordAbnormal: (): Promise<any> => getSelectListByParams({ type: 24, field: 'name' }),

    // 生产管理-产线运行工单-数据采集
    runRecordCollection: (): Promise<any> => getSelectListByParams({ type: 25, field: 'name' }),

    // 生产管理-产线运行工单-数据采集详情
    runRecordCollectionDetail: (): Promise<any> => getSelectListByParams({ type: 26, field: 'name' }),

    // 生产管理-产线运行工单-工序流程
    runRecordProcedure: (): Promise<any> => getSelectListByParams({ type: 27, field: 'name' }),

    // 生产管理-产线运行工单-设备报检
    runRecordProcedureCheckInspection: (): Promise<any> => getSelectListByParams({ type: 28, field: 'name' }),

    // 生产管理-产线运行工单-设备运行过程记录
    runRecordProcedureEquipmentRunProcessRecord: (): Promise<any> => getSelectListByParams({ type: 29, field: 'name' }),

    // 生产管理-产线运行工单-设备运行时长记录
    runRecordProcedureEquipmentRunTimeRecord: (): Promise<any> => getSelectListByParams({ type: 30, field: 'name' }),

    // 生产管理-产线运行工单-表单配置
    runRecordProcedureFormSet: (): Promise<any> => getSelectListByParams({ type: 31, field: 'name' }),

    // 生产管理-产线运行工单-表单配置采集项目
    runRecordProcedureFormCollection: (): Promise<any> => getSelectListByParams({ type: 32, field: 'name' }),

    // 生产管理-产线运行工单-表单配置采集项目指标设置
    runRecordProcedureFormCollectionStandard: (): Promise<any> => getSelectListByParams({ type: 33, field: 'name' }),

    // 生产管理-产线运行工单-工序流程设置
    runRecordProcedureSet: (): Promise<any> => getSelectListByParams({ type: 34, field: 'name' }),

    // 部门下拉
    departmentPullDown: (): Promise<any> => getSelectListByParams({ type: 49, field: 'name' }),

    // 客户下拉
    customerList: (): Promise<any> => getSelectListByParams({ type: 50, field: 'name' }),

    // 气瓶编号下拉
    cylinderNumList: (): Promise<any> => getSelectListByParams({ type: 52, field: 'cylinder_num' }),

    // 供应商下拉
    supplierList: (): Promise<any> => getSelectListByParams({ type: 154, field: 'name' }),

    //物料名称
    materialName: (): Promise<any> => getSelectListByParams({ type: 103, field: 'name' }),

    //物料信息
    materialInfo: (): Promise<any> => getSelectListByParams({ type: 103, field: 'code,name' }),

    //物料列表
    materialList: (): Promise<any> => getSelectListByParams({ type: 103, field: 'code' }),

    //物料规格
    materialSpecification: (): Promise<any> => getSelectListByParams({ type: 103, field: 'material_specification' }),

    //计量单位
    measureUnit: (): Promise<any> => getSelectListByParams({ type: 107, field: 'name' }),

    //产线运行单
    productionRunOrder: (): Promise<any> =>
        getSelectListByParams({ type: 121, field: 'code,production_line_name', queryCriteria: 'status = 3' }),

    // 基础数据-生产资料-生产线
    productionLine: (): Promise<any> => getSelectListByParams({ type: 133, field: 'name' }),

    // 基础数据-质量资料-检验方案
    getInspectionScheme: (data?: unknownType): Promise<any> =>
        getSelectListByParams({ type: 150, field: 'name', ...data }),

    // 姓名 - 用户表
    getUserNameList: (): Promise<any> => getSelectListByParams({ type: 166, field: 'user_name' }),

    // 供应商列表详情
    supplierDetail: (data?: httpData) => {
        return get('/supplier/detail', data);
    },
    // 获取菜单角标
    getAppWaitHandleCount: (data?: httpData) => {
        return get('/common/getAppWaitHandleCount', data);
    },
    // 部门下拉
    getComDepList: (data?: httpData) => {
        return get('/company/selectCompanyDept', data);
    },
    // 生产订单号
    orderProductionPullDown: (data?: httpData) => {
        return get('/order/production/dropdown', data);
    },
    // 销售订单号
    getSaleOrderList: (): Promise<any> => getSelectListByParams({ type: 125, field: 'code' }),

    // 仓库编码
    getWarehouseCodeList: (): Promise<any> => getSelectListByParams({ type: 201, field: 'warehouse_num' }),

    // 仓库编码/仓库名称下拉
    getWarehouseCodeAndNameList: (): Promise<any> => {
        return get('/warehouse/location/getPullDownTwo');
    },

    // 客户和供应商下拉
    customerAndSupplierPullDown: (): Promise<any> => {
        return get('/warehouse/enter/empty/cylinderSource/pullDown');
    },
    // 库位下拉
    getLocationList: (): Promise<any> => getSelectListByParams({ type: 202, field: 'location_explain' }),
    // 库位下拉
    getLocationDown: (data: { warehouseId: string }): Promise<any> => {
        return get('/warehouse/location/dropDownByWarehouseId', data);
    },
    /**
     * 实盘库位
     */
    dropDownByWarehouse: (data: any): Promise<any> => {
        return get('/warehouse/location/dropDownByWarehouseId', data);
    },

    /**
     * 设备名称
     */
    equipmentNameList: (data: any): Promise<any> => {
        return get('/equipment/card/dropdownName', data);
    },
    /**
     * 检验方案 - 根据报检单id
     */
    standardList: (data: any): Promise<any> => {
        return get('/quality/order/inspection/detail/dropdown/standard', data);
    },
};
